﻿using System.Windows;
using Informant.Clients.DataProviders;
using Informant.Clients.DataProviders.Wpf4.InformantService;
using Informant.Clients.Views;

namespace Informant.Clients.UI.Wpf4
{
	/// <summary>
	/// Interaction logic for App.xaml
	/// </summary>
	public partial class App
	{
		/// <summary>
		/// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
		/// </summary>
		/// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
		protected override void OnStartup(StartupEventArgs e)
		{
			//Register DataProviders (First because they may be used in the construction of some UI)
			var informantServiceDataProvider = new InformantServiceDataProvider();
			Controller.Instance.Register<IInformantServiceDataProvider>(informantServiceDataProvider);

			//Register ViewContainers
			var mainWindow = new MainWindow();
			Controller.Instance.Register<IViewContainer>(mainWindow);

			//Register Views
			Controller.Instance.Register<ILogOnView>(new LogOnView());
			Controller.Instance.Register<ISmsMessagingView>(new SmsMessagingView());

			mainWindow.Navigate(Controller.Instance.Get<ILogOnView>());
			Current.MainWindow = mainWindow;
			Current.MainWindow.Show();
			base.OnStartup(e);
		}
		/// <summary>
		/// Raises the <see cref="E:System.Windows.Application.Exit"/> event.
		/// </summary>
		/// <param name="e">An <see cref="T:System.Windows.ExitEventArgs"/> that contains the event data.</param>
		protected override void OnExit(ExitEventArgs e)
		{
			Controller.Instance.Dispose();
			base.OnExit(e);
		}
	}
}
